﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using MySql.Data.MySqlClient;

namespace ATM
{
    public partial class Log_In : Form
    {
      
        public Log_In()
        {
            InitializeComponent();
            result.PasswordChar = '*';
            result.MaxLength=12;
        }

        

        private void button1_Click(object sender, EventArgs e)
        {

        }

        private void button1_Click_1(object sender, EventArgs e)
        {
            try
            {
                string myconnection = "datasource=localhost;port=3306;username=root;password=nitro";
                MySqlConnection myconn = new MySqlConnection(myconnection);
                MySqlCommand SelectCommand = new MySqlCommand("SELECT * FROM atm.atm_customers where Account_Number='" + this.result.Text +  "';", myconn);
                MySqlDataReader myreader;

                myconn.Open();
                myreader = SelectCommand.ExecuteReader();
                int count = 0;
             
                while (myreader.Read())
                {
                    count = count + 1;
                }
                if (count == 1)
                {

                  
                    this.Hide();
                    inter_face frm = new inter_face ();
                    frm.Show();
                    
                }
                else
                    MessageBox.Show("Uncorrect Number");
                result.Clear();

                myconn.Close();

            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            


        }

        private void result_TextChanged(object sender, EventArgs e)
        {

        }

        private void button12_Click(object sender, EventArgs e)
        {
            result.Clear();
        }

        private void button13_Click(object sender, EventArgs e)
        {
            Close();
        }

        private void groupBox1_Enter(object sender, EventArgs e)
        {

        }

    }
}
